# coding=utf-8
# 全世界最帅的帅哥
from datetime import timedelta
from pathlib import Path

from ysgg1_club_subject.comment.utils.decrypt_util import PRIVATE_KEY_PATH
from ysgg1_club_subject.comment.utils.decrypt_util import decrypt

utils_path = Path(PRIVATE_KEY_PATH).parent.absolute()


class Config:
    # 配置数据库和SQLALCHEMY
    HOSTNAME = '121.40.187.211'
    PORT = '3306'
    DATABASE = 'ysgg1_club'
    USERNAME = 'root'
    ENCRYPTED_DATA = utils_path / 'encrypted_data.bin'
    ENCRYPTED_MAIL_DATA = utils_path / 'encrypted_mail_data.bin'
    # 密码加密
    DB_URI = "mysql+pymysql://{0}:{1}@{2}:{3}/{4}?charset=utf8mb4".format(USERNAME, decrypt(ENCRYPTED_DATA), HOSTNAME,
                                                                          PORT, DATABASE)
    DEBUG = True
    SQLALCHEMY_ECHO = True
    SQLALCHEMY_DATABASE_URI = DB_URI
    # 不需要做数据追踪
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 日志的配置
    LOGGING_LEVEL = "INFO"
    LOGGING_FILE_DIR = Path(__file__).parent.parent / "logs"
    LOGGING_FILE_MAX_BYTES = 300 * 1024 * 1024
    LOGGING_BACKUP = 10

    # JWT配置
    JWT_TOKEN_LOCATION = ["headers", "cookies", "json"]
    JWT_SECRET_KEY = '0c22522f23fd61c8a677bf8f5b073442'
    JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1)
    JWT_REFRESH_TOKEN_EXPIRES = timedelta(days=30)

    # CELERY 配置
    CELERY_RESULT_BACKEND = "redis://:ACceSsysgg1234@121.40.187.211:6379/3"
    CELERY_BROKER_URL = "amqp://admin:admin@121.40.187.211//"
    task_serializer = "json",
    result_serializer = "json",
    timezone = "Asia/Shanghai",
    enable_utc = False,
    result_expires = 3600
